#region
/* Adoor.NET - Object/Relational mapping framework leveraging ADO.NET`s powerful disconnected mode.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *  
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *  
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */ 
#endregion

using Adoor.Expression.AST;

namespace Adoor.Expression
{
    /// <summary>
    /// Default IExpressionVisitor implementation
    /// </summary>
    public abstract class ExpressionNavigator : IExpressionVisitor
	{
		public virtual void VisitName(ExpressionName n)
		{
			// nothing
		}

		public virtual void VisitEscape(ExpressionEscape e)
		{
			// nothing
		}

		public virtual void VisitParen(ExpressionParen p)
		{
			p.Exp.Accept(this);
		}

		public virtual void VisitPrimary(ExpressionPrimary p)
		{
			// nothing
		}

		public virtual void VisitUnary(ExpressionUnary u)
		{
			u.Exp.Accept(this);
		}

		public virtual void VisitBinary(ExpressionBinary b)
		{
			b.Exp1.Accept(this);
			b.Exp2.Accept(this);
		}

		public virtual void VisitIs(ExpressionIs i)
		{
			i.Exp.Accept(this);
		}

		public virtual void VisitLike(ExpressionLike l)
		{
			l.Exp1.Accept(this);
			l.Exp2.Accept(this);
		}

		public virtual void VisitFunction(ExpressionFunction f)
		{
			foreach(ExpressionNode en in f.Parameters)
				en.Accept(this);
		}

		public virtual void VisitIn(ExpressionIn j)
		{
			for (int i = 0; i < j.Nodes.Length; i++)
			{
				j.Nodes[i].Accept(this);				
			}

			j.Exp.Accept(this);
		}

		public virtual void VisitInSubQuery(ExpressionInSubquery j)
		{
			j.Exp.Accept(this);			
		}

		public virtual void VisitExistsSubQuery(ExpressionExistsSubquery j)
		{
		
		}

		public virtual void VisitCorrelationFilteredNode(ExpressionCorrelationFilteredNode c)
		{
			foreach(ExpressionNode en in c.Nodes.Values)
				en.Accept(this);
			c.DefaultNode.Accept(this);
		}
	}
}
